<template>
  <div>
      <el-dialog  class="logindialog" :close-on-press-escape="false" top="40px" :width="iframestyle.width" :close-on-click-modal="false" :show-close="false" :visible.sync="dialogloginVisible" >
          <iframe v-if="dialogloginVisible" :style="iframestyle" :src="framurl" id="myiframe" scrolling="no"  frameborder="0"></iframe>
      </el-dialog>
  </div>
</template>
<script type="es6">
import EventBus from '../../libs/eventBus';
export default {
  data () {
    return {
      logindialog: false,
      framurl: '',
      iframestyle: {
        width: '900px',
        height: '327px'
      },
      dialogloginVisible: false
    };
  },
  methods: {
    show (URL) {
      this.framurl = URL + window.location.origin + '/ssologin';
      this.dialogloginVisible = true;
      window.closeLogin = (user) => {
        EventBus.$emit('SSOuser', user);
        this.$notify({
          title: '登录成功',
          type: 'success'
        });
        this.hidelogin();
      };
    },
    hidelogin () {
      this.dialogloginVisible = false;
    },
    Redirect (URL) {
      let URLS = URL + window.location.origin + '/ssologin';

      window.localStorage.removeItem('ssobackurl');
      window.localStorage.setItem('ssobackurl', window.location.href);
      window.location.href = URLS;

      window.closeLogin = (user) => {
        window.getSSOuser = () => {
          return user;
        };
        window.location.href = localStorage.ssobackurl;
        localStorage.removeItem('ssobackurl');
      };
      localStorage.removeItem('closeLogin');
      window.localStorage.setItem('closeLogin', window.closeLogin);
    }
  },
  mounted () {

  }
};
</script>
<style lang="less">
    .logindialog{
        .el-dialog__header{
            padding: 0;
        }
        .el-dialog__body{
            padding: 0;
        }
    }
</style>
